package com.hhkj.study.admin.goods.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hhkj.study.common.entity.BaseJsonItem;
import com.hhkj.study.common.logic.ListBaseJacksonHandler;
import com.ruoyi.common.core.domain.BizBaseEntity;
import com.ruoyi.common.valid.VAdd;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
*
* @author SERVER
* @since 2024-09-18
*/
@TableName(value = "x_goods_sku")
@EqualsAndHashCode(callSuper = true)
@Data
public class GoodsSku extends BizBaseEntity {

	@NotNull(message = "商品id不能为空", groups = VAdd.class)
	private Long goodsId;

	/**
	 * 名称
	*/
	@NotBlank(message = "名称不能为空", groups = VAdd.class)
	private String name;
	/**
	 * sku编码
	*/
	private String code;
	/**
	 * 课程idList
	*/
	@TableField(exist = false)
	private List<Long> courseIdList;

	/**
	 * 课程idList
	 */
	@TableField(typeHandler = ListBaseJacksonHandler.class)
	private List<BaseJsonItem> courseList;

	/**
	 * 原始价格
	*/
	private Integer originPrice;
	/**
	 * 现价
	*/
	private Integer realPrice;

	public List<Long> getCourseIdList() {
		List<Long> idList = new ArrayList<>();
		if (courseList == null || courseList.size() == 0) {
			return idList;
		}
		for (BaseJsonItem item : courseList) {
			idList.add(item.getId());
		}
		return idList;
	}

}